<template>
    <div class=" ">
        <div class=" content">
            <div class="top-title">
                新闻中心
            </div>
            <div class="content-box">
                <div class="left-box">
                    <div class="title">新闻中心</div>
                    <div class="item-box">
                        <div class="item" v-for="(item, index) in newsListData.newslist" :key="index"
                            @click="goto('/newscontent', item.checkId, item.newsid)">
                            >> {{ item.title }}
                        </div>
                    </div>
                </div>
                <div class="right-box">
                    <div class="title">产品新闻</div>
                    <div class="item-box">
                        <div class="item" v-for="(item, index) in newsListData.chanpinlist" :key="index"
                            @click="goto('/newscontent', item.checkId, item.newsid)">
                            >> {{ item.title }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script setup>

import { ref, reactive, onMounted, onBeforeUnmount, watch } from 'vue';
import router from '../router/index.js'; // 导入路由实例
import { base64Img } from '../tools/tools.js'
import { getNewsList, getChanPinXiangqing, } from '../api/api/ProducView.js'
import { useRoute } from 'vue-router'
const route = useRoute()
const newsListData = ref([])

// 跳转
const goto = (path, checkData, newsId) => {
    router.push({
        path: path,
        query: {
            checkData: checkData,
            newsId: newsId
        }
    })
}



// 获取公司新闻
const _getNewsList = () => {
    getNewsList('sj1').then((res) => {
        console.log('新闻信息', res);
        newsListData.value = res.data
    })
}

onMounted(() => {
    _getNewsList()
});

</script>

<style lang="scss" scoped>
// 取消显示手机端 显示pc端
@media (min-width: 800px) {
    .content {
        width: 1200px;
        margin: 0 auto;

        .top-title {

            text-align: center;
            line-height: 60px;
            font-size: 30px;
            margin-bottom: 20px;
            border-bottom: 1px solid gainsboro;
        }

        .content-box {
            display: flex;
            justify-content: space-around;
            margin-bottom: 20px;

            .left-box {
                background-color: white;

                width: 580px;
                border: 1px solid gainsboro;
                min-height: 400px;

                .title {
                    padding: 10px 0 10px 20px;
                    background-color: #f7f7f7;
                    border-bottom: 1px solid #dedede;
                }

                .item-box {
                    .item {
                        line-height: 40px;
                        padding-left: 10px;
                        border-bottom: 1px solid gainsboro;
                        cursor: pointer;
                        white-space: nowrap;
                        /* 不换行 */
                        overflow: hidden;
                        /* 溢出隐藏 */
                        text-overflow: ellipsis;
                        /* 用省略号表示溢出 */
                    }

                    .item:hover {
                        color: orange;
                        border-bottom: 1px solid orange;
                    }
                }
            }

            .right-box {
                width: 580px;
                border: 1px solid gainsboro;
                min-height: 400px;
                background-color: white;

                .title {
                    padding: 10px 0 10px 20px;
                    background-color: #f7f7f7;
                    border-bottom: 1px solid #dedede;
                }

                .item-box {
                    .item {
                        line-height: 40px;
                        padding-left: 10px;
                        border-bottom: 1px solid gainsboro;
                        cursor: pointer;
                    }

                    .item:hover {
                        color: orange;
                        border-bottom: 1px solid orange;
                    }
                }
            }
        }
    }
}

// 取消显示pc端 显示手机端
@media screen and (max-width: 799px) {
    .top-title {
        display: none;
    }

    .title {
        line-height: 60px;
        font-size: 26px;
        font-weight: 700;
        text-align: center;
        border-bottom: 1px solid gainsboro;
        margin-bottom: 10px;
        margin-top: 30px;
    }

    .content-box {
        padding: 20px;

        .left-box {}
    }
}
</style>